﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.CancelDelayService, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_CancelDelayService : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.CancelDelayService;

        public override string name => LevelEditorConst.CancelDelayService;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.CancelDelayService, "定位目标方式")]
        public int isByEntity;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.CancelDelayService, "实体ID/服务GUID"), Tooltip("和定位目标方式统一")]
        public int searchId;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_CancelDelayService()
            {
                isByEntity = this.isByEntity == 0,
                searchId = this.searchId,
            };
            return rConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (tempNode is LevelServiceExecutionNode_CancelDelayService rNode)
            {
                this.isByEntity = rNode.isByEntity;
                this.searchId = rNode.searchId;
            }
        }
    }
}